import requests
import re

class Doutu:
    header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)\
Chrome/67.0.3396.62 Safari/537.36X-DevTools-Emulate-Network-Conditions-Client-Id: 8A87E3B23FD7D609C85FDFAB0D0B0E13'}
    
    def __init__(self,key_word = '得意',
                 url = 'http://www.doutula.com/search',
                 charset = 'utf-8'):
        self.s = requests.Session()
        self.key_word = key_word
        self.url = url
        self.charset = charset
        self.html = self.gethtml()
    def gethtml(self):
        param = {'keyword':self.key_word}
        
        res = self.s.get(self.url,params = param,headers = self.header)
        
        res.encoding = self.charset
        res_html = res.text
        
        return res_html
    
    def getimage(self):
        img_re = 'data-backup="(.*?)"'
        img = re.findall(img_re,self.html,re.S)
        
        return img
if __name__ =='__main__':
    d = Doutu().getimage()
    print(d)



























        
